﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WinnerCMS.BLL;
using WinnerCMS.Common;

#endregion

namespace WinnerCMS.WebUI.Admin.Member
{
    public partial class RoleList : WebFactory.PageBase
    {
        private int UserID;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.UserID = int.Parse(Request["UserID"]);
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            ServerControl.BindDropDownList(this.ListBox1, new RoleManage().GetListNotIn(this.UserID, false), "RoleName",
                "ID",
                null);

            ServerControl.BindDropDownList(this.ListBox2, new RoleManage().GetListIn(this.UserID, false), "RoleName",
                "ID",
                null);
        }

        protected void btnTakeIt_Click(object sender, EventArgs e)
        {
            if (this.ListBox2.SelectedIndex < 0)
            {
                MsgBox.Message("请选择。", this.UpdatePanel1);
                return;
            }
            new RoleManage().TakeIt(this.UserID, int.Parse(this.ListBox2.SelectedValue));
            Bind();
        }

        protected void btnAuthorizeIt_Click(object sender, EventArgs e)
        {
            if (this.ListBox1.SelectedIndex < 0)
            {
                MsgBox.Message("请选择。", this.UpdatePanel1);
                return;
            }
            new RoleManage().AuthorizeIt(this.UserID, int.Parse(this.ListBox1.SelectedValue));
            Bind();
        }
    }
}